package CutLoad.transitions.fireworks
{
	import flash.display.Sprite;
	import flash.events.Event;
	public class Fireworks extends Sprite {
		private var units:Array=new Array();
		private var delayFrame:Number=-1;
		private var counter:Number=0;
		public function Fireworks(color:Number):void{
			var i:Number;
			for(i=0;i<40;i++){
				units[i]=new FireUnit(1,color);
			}
			for(i=40;i<60;i++){
				units[i]=new FireUnit(2,color);
			}
			for(i=60;i<85;i++){
				units[i]=new FireUnit(3,color);
			}
			addEventListener(Event.ENTER_FRAME,this.onEnterFrame3);
			reset();
		}
		public function bombing():Boolean{
			return counter>=0;
		}
		public function reset():void{
			for(var i:Number=0;i<units.length;i++){
				units[i].x=units[i].y=0;
				units[i].scaleX=units[i].scaleY=0.6+Math.random()%0.4;
				addChild(units[i]);
				units[i].reset();
			}
			counter=10;
		}
		private function onEnterFrame3(e:Event):void{
			if(delayFrame>0){
				delayFrame--;
				return;
			}
			if(delayFrame==0){
				delayFrame--;
			}
			for(var i:Number=0;i<units.length;i++){
				units[i].loop();
			}
			counter--;
		}
		public function bomb(delayFrame:Number=0):void{
			this.delayFrame=delayFrame;
			for(var i:Number=0;i<units.length;i++){
				units[i].startMove(50*Math.random(),Math.random()*360);
			}
		}
	}
}